Skip to main content

All Questions

Tagged with
5votes
2answers
349views

PHP Fisher-Yates shuffle with random_int

The PHP manual states that the regular shuffle() function isn't cryptographically secure, but that random_int() is. I thought, ...
James G.'s user avatar
2votes
2answers
102views

delete multidimentional array value in php

I made a program that converts JSON to a PHP array and checks every value of the multidimensional array with a loop and if a value matches certain values then it deletes that key and value and ...
mahmoudkhani's user avatar
2votes
1answer
127views

function to group data by parent branches

I wrote this function to take database output like from PDO's fetchAll(PDO::FETCH_ASSOC) and turn it into a tree. For small datasets it works well. However, when ...
aswine's user avatar
4votes
3answers
1kviews

Filter an array, but remove the filtered elements

I needed a PHP function that would filter values from one array into a new one, while also removing those values from the original array. After looking through the docs, I didn't see any such function,...
Bee H.'s user avatar
0votes
1answer
89views

PHP assign values within in_array

What is a more efficient way of writing this sample code? Its purpose is to create a variable for days of the week based on a numerical value. This data is obtained from user input checkboxes. If the ...
Tim M's user avatar
4votes
2answers
186views

Modify a WordPress loop to show posts of certain categories, based on user roles

I've got some code that works as intended, but I have a feeling that it's messy. This code is modifying a wordpress loop and the goal is to check the roles of the current user and show posts of ...
JLW's user avatar
  • 43
1vote
1answer
159views

implode on two level dimensions array

I have an array like this ...
Matías Cánepa's user avatar
3votes
1answer
140views

a php function to check a 'deep' array value

I've just coded a little function to check and get a deep array value. Basically, I need to return the value or null if it's not set or does not exists, or in general not useful for databases records. ...
Luca Reghellin's user avatar
2votes
2answers
626views

remove ALL duplicate elements from an array

I have this code to remove duplicates (all occurrences) from an associative array, does PHP have methods to do this ? Or is there a way to improve the code ? I looked for array_unique, array_search, ...
aurepito's user avatar
3votes
3answers
607views

Find common timeslots for consecutive days

Imagine you want to reserve a classroom over several days. You get a schedule, from the school, telling you when a certain classroom is still free. To make it easy for your students, you want to ...
KIKO Software's user avatar
2votes
2answers
2kviews

Sort array of dates

I have this array with dates. All the dates are checked before creating the array with preg_match and check_dates. GoodDates ( ...
Nasty Phoenix's user avatar
1vote
1answer
2kviews

PHP Group associative Array duplicates and make subarrays of different values

I have this type of table: ...
aurepito's user avatar
1vote
2answers
102views

Check URL for keywords [closed]

I'm looking at improving my PHP knowledge and wondering if anybody has any tips on improving and optimising my function below? ...
stu's user avatar
  • 21
2votes
1answer
325views

PHP update multidimensional array values from same path multidmensional array

I need to update a multidimensional array by same key paths of a multidimensional array. I think my code can be better condensed : ...
aurepito's user avatar
2votes
0answers
54views

editing the array I've included instead of editing the file of included array php

In order to reduce time complexity, instead of loading (and then dumping to use it for later) the whole file into an array (It would be O(n) with n=number of lines), I have saved it as array into a ...
Matteo's user avatar

153050per page
close